from enum import Enum
from pydantic import BaseModel, Field
from typing import List, Optional


class SubmittedFormContentUserCreate(BaseModel):
    form_rule_id: Optional[int] = Field(..., description="成果表单规则ID")
    text_info: Optional[str] = Field(None, description="文字信息")
    file_link: Optional[str] = Field(None, description="文件链接")


class SubmittedFormUserCreate(BaseModel):
    achievement_id: Optional[int] = Field(..., description="成果表ID")
    contents: List[SubmittedFormContentUserCreate] = Field(..., description="提交表单内容")

    class Config:
        json_schema_extra = {
            "example": {
                "achievement_id": 1,
                "contents": [
                    {
                        "form_rule_id": 1,
                        "text_info": "成果文字信息",
                        "file_link": "file.pdf"
                    }
                ]
            }
        }


class SubmittedFormQuery(BaseModel):
    id: Optional[int] = Field(..., description="成果表ID")
    status: Optional[str] = Field(None, description="成果表状态")  # 默认是 None，表示可选
    page: int = Field(1, description="页数")  # 默认是第一页
    length: int = Field(20, description="每页的条目数")  # 默认是20条


class SubmittedFormContentQuery(BaseModel):
    id: Optional[int] = Field(..., description="提交成果ID(achievement_form_id)")


class ReviewTypeEnum(str, Enum):
    approved = "approved"
    rejected = "rejected"


class SubmittedReview(BaseModel):
    id: Optional[int] = Field(..., description="成果内容ID(submitted_form_content_id)")
    comment: str = Field(None, description="审批意见")
    type: Optional[ReviewTypeEnum] = Field(None, description="审批结果")
